<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>cocoOS: C:/Users/peter_000/Desktop/cocoOS/common/src/os_kernel.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">cocoOS
   &#160;<span id="projectnumber">5.0.3</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('os__kernel_8c.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">os_kernel.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;cocoos.h&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a6cc2e63d83267ff5059bf0a76b302a09"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a6cc2e63d83267ff5059bf0a76b302a09">os_init</a> (void)</td></tr>
<tr class="separator:a6cc2e63d83267ff5059bf0a76b302a09"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a19c7111cf2121a69331d99dabe3e9df0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a> (void)</td></tr>
<tr class="separator:a19c7111cf2121a69331d99dabe3e9df0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1d7bc0554f6b515785211dd2c3f2d3d9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a1d7bc0554f6b515785211dd2c3f2d3d9">os_tick</a> (void)</td></tr>
<tr class="separator:a1d7bc0554f6b515785211dd2c3f2d3d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac48c31882821ef8c2acef85235ee3d13"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#ac48c31882821ef8c2acef85235ee3d13">os_sub_tick</a> (uint8_t id)</td></tr>
<tr class="separator:ac48c31882821ef8c2acef85235ee3d13"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5b490624895d2f8132bce27f81e7027f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a5b490624895d2f8132bce27f81e7027f">os_sub_nTick</a> (uint8_t id, uint32_t nTicks)</td></tr>
<tr class="separator:a5b490624895d2f8132bce27f81e7027f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a943c88e42849b98b803f707d134baf79"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a943c88e42849b98b803f707d134baf79">os_running</a> (void)</td></tr>
<tr class="separator:a943c88e42849b98b803f707d134baf79"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4aa5411405c3a76e6de7f041edce05fa"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a4aa5411405c3a76e6de7f041edce05fa">os_get_running_tid</a> (void)</td></tr>
<tr class="separator:a4aa5411405c3a76e6de7f041edce05fa"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:a6857a184b9ad06cadd24899296af802a"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#a6857a184b9ad06cadd24899296af802a">running_tid</a></td></tr>
<tr class="separator:a6857a184b9ad06cadd24899296af802a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac70e02976aa8431691b8fcba2ecb779d"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#ac70e02976aa8431691b8fcba2ecb779d">last_running_task</a></td></tr>
<tr class="separator:ac70e02976aa8431691b8fcba2ecb779d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af77f8244799e85284b8b438289f5f689"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__kernel_8c.html#af77f8244799e85284b8b438289f5f689">running</a></td></tr>
<tr class="separator:af77f8244799e85284b8b438289f5f689"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a4aa5411405c3a76e6de7f041edce05fa"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t os_get_running_tid </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a6cc2e63d83267ff5059bf0a76b302a09"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void os_init </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Initializes the scheduler. </p><dl class="section return"><dt>Returns</dt><dd>None. </dd></dl>
<dl class="section remark"><dt>Remarks</dt><dd><b>Usage:</b> <br />
 Should be called early in system setup, before starting the task execution</dd></dl>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;int main(void) {</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;system_init();</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;os_init();</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;...</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="a943c88e42849b98b803f707d134baf79"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t os_running </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a19c7111cf2121a69331d99dabe3e9df0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void os_start </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Starts the task scheduling</p>
<dl class="section return"><dt>Returns</dt><dd>None. </dd></dl>
<dl class="section remark"><dt>Remarks</dt><dd><b>Usage:</b> <br />
 Should be the last line of main.</dd></dl>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;int main(void) {</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  system_init();</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  os_init();</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;  task_create( myTaskProc, 1, NULL, 0, 0 );</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;  ...</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;  os_start();</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;  return 0;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="a5b490624895d2f8132bce27f81e7027f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void os_sub_nTick </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>nTicks</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Tick function driving the sub clocks. Increments the tick count with nTicks.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>sub clock id, allowed range 1-255. </td></tr>
    <tr><td class="paramname">nTicks</td><td>increment size, 16 bit value. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None. </dd></dl>
<dl class="section remark"><dt>Remarks</dt><dd><b>Usage:</b> <br />
 Could be called at any desired rate to trigger timeouts. Called from a task or from an interrupt ISR.</dd></dl>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;ISR(SIG_OVERFLOW0) {</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  ...</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  os_sub_nTick( 2, 10 );</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="ac48c31882821ef8c2acef85235ee3d13"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void os_sub_tick </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Tick function driving the sub clocks</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>sub clock id, allowed range 1-255</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None. </dd></dl>
<dl class="section remark"><dt>Remarks</dt><dd><b>Usage:</b> <br />
 Could be called at any desired rate to trigger timeouts. Called from a task or from an interrupt ISR.</dd></dl>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;ISR(SIG_OVERFLOW0) {</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  ...</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  os_sub_tick(2);</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;}</div>
</div><!-- fragment --> 
</div>
</div>
<a class="anchor" id="a1d7bc0554f6b515785211dd2c3f2d3d9"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void os_tick </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Tick function driving the kernel</p>
<dl class="section return"><dt>Returns</dt><dd>None. </dd></dl>
<dl class="section remark"><dt>Remarks</dt><dd><b>Usage:</b> <br />
 Should be called periodically. Preferably from the clock tick ISR.</dd></dl>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;ISR(SIG_OVERFLOW0) {</div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  ...</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  os_tick();</div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;}</div>
</div><!-- fragment --> 
</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a class="anchor" id="ac70e02976aa8431691b8fcba2ecb779d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t last_running_task</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="af77f8244799e85284b8b438289f5f689"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t running</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a6857a184b9ad06cadd24899296af802a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t running_tid</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_bdd9a5d540de89e9fe90efdfc6973a4f.html">common</a></li><li class="navelem"><a class="el" href="dir_4e4d22e38ca4e2e8207825ee2d00bc54.html">src</a></li><li class="navelem"><a class="el" href="os__kernel_8c.html">os_kernel.c</a></li>
    <li class="footer">Generated on Tue Aug 28 2018 17:58:05 for cocoOS by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.9.1 </li>
  </ul>
</div>
</body>
</html>
